package com.sen.mybatis.mapper;

import com.sen.mybatis.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 王浩森
 * @since 2021-01-16
 */
@Repository
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT u.user_id,u.user_name,u.password,u.sex,u.address,u.birthday,t.type_id,t.type_name FROM sys_user u,sys_type t WHERE u.type_id=t.type_id")
    List<User> findUsers();

    @Select("select * from sys_user where user_name=#{userName} and password=#{password}")
    User login(@Param("userName") String userName,@Param("password") String password);

    @Select("select * FROM sys_user u,sys_type t WHERE u.type_id=t.type_id AND u.user_id=#{userId}")
    User getUserById(@Param("userId") Integer userId);

    @Select("UPDATE sys_user u  SET u.user_name=#{userName} WHERE u.user_id=#{userId}")
    User updateVo(@Param("userId") Integer userId,@Param("userName") String userName);
    @Select("DELETE FROM sys_user WHERE user_id=#{userId}")
    User deleteVo(@Param("userId") Integer userId);
}
